﻿namespace WMS6.Web.TransportManagement
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class TrackingQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlBolID;
        protected DropDownList ddlCarrierID;
        protected DropDownList ddlCreateBy;
        protected DropDownList ddlDeliveryOrderID;
        protected DropDownList ddlDriverID;
        protected DropDownList ddlDriverPhone;
        protected DropDownList ddlEquipmentLicence;
        protected DropDownList ddlStatus;
        protected DropDownList ddlStatusValue;
        protected DropDownList ddlTrackingDate;
        protected HtmlForm F8040;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlImage img2;
        protected Label lblBolID;
        protected Label lblBu;
        protected Label lblCarrierID;
        protected Label lblCreateBy;
        protected Label lblDeliveryOrderID;
        protected Label lblDriverID;
        protected Label lblDriverPhone;
        protected Label lblEquipmentLicence;
        protected Label lblStatus;
        protected Label lblTrackingDate;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtBolID;
        protected TextBox txtCarrierID;
        protected TextBox txtCreateBy;
        protected TextBox txtDeliveryOrderID;
        protected TextBox txtDriverID;
        protected TextBox txtDriverPhone;
        protected TextBox txtEquipmentLicence;
        protected TextBox txtTrackingDate;
        protected TextBox txtTrackingDate2;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("TrackingList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("TrackingList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadDll()
        {
            base.BindData2DDLBySysCode(this.ddlStatusValue, "BolStatus");
            this.ddlStatusValue.Items.Insert(0, new ListItem("-----", ""));
            base.InitQueryDDL(this.ddlBolID, 0);
            base.InitQueryDDL(this.ddlDeliveryOrderID, 0);
            base.InitQueryDDL(this.ddlEquipmentLicence, 0);
            base.InitQueryDDL(this.ddlCarrierID, 0);
            base.InitQueryDDL(this.ddlDriverID, 0);
            base.InitQueryDDL(this.ddlDriverPhone, 0);
            base.InitQueryDDL(this.ddlStatus, 0);
            base.InitQueryDDL(this.ddlTrackingDate, 1);
            base.InitQueryDDL(this.ddlCreateBy, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDll();
                if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
                {
                    this.btnExport.Visible = false;
                    this.btnNew.Visible = false;
                }
            }
        }

        public string BolID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBolID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtBolID.Text.Trim(), this.ddlBolID.SelectedValue);
                }
                return "";
            }
        }

        public string CarrierID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCarrierID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCarrierID.Text.Trim(), this.ddlCarrierID.SelectedValue);
                }
                return "";
            }
        }

        public string CreateBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreateBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreateBy.Text.Trim(), this.ddlCreateBy.SelectedValue);
                }
                return "";
            }
        }

        public string DeliveryOrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDeliveryOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDeliveryOrderID.Text.Trim(), this.ddlDeliveryOrderID.SelectedValue);
                }
                return "";
            }
        }

        public string DriverID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDriverID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDriverID.Text.Trim(), this.ddlDriverID.SelectedValue);
                }
                return "";
            }
        }

        public string DriverPhone
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDriverPhone.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDriverPhone.Text.Trim(), this.ddlDriverPhone.SelectedValue);
                }
                return "";
            }
        }

        public string EquipmentLicence
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEquipmentLicence.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEquipmentLicence.Text.Trim(), this.ddlEquipmentLicence.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlStatusValue.SelectedValue))
                {
                    return base.GetParamsString(this.ddlStatusValue.SelectedValue, this.ddlStatus.SelectedValue);
                }
                return "";
            }
        }

        public string TrackingDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtTrackingDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtTrackingDate.Text.Trim(), this.ddlTrackingDate.SelectedValue, this.txtTrackingDate2.Text.Trim(), "TrackingDate");
                }
                return "";
            }
        }
    }
}

